package A07Object;

import java.util.Objects;

public class Student extends Object implements Cloneable{//此处Cloneable是标志接口
    public String name;
    public int age;
    public int[] arr=new int[4];
    public Student(){

    }
    public Student(String name, int age, int[] arr) {
        this.name = name;
        this.age = age;
        this.arr = arr;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public String toString() {
        return "Student [name=" + name + ", age=" + age + "]"+this.arr[2];
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name);//此处为OBjects，故比较的不是地址值
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {

        /*int[] data=this.arr;
        int[] data1=new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            data1[i]=data[i];
        }
        Student s1=(Student) super.clone();
        s1.arr=data1;
        return s1;*/

        return super.clone();
    }
}
